// 数据库连接文件
// 连接postgres数据库

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/jackc/pgx/v5"
)

// 登录数据库函数
func connectToDB() {
	url := "postgres://testuser:123456@localhost:5432/testdb"
	var err error
	conn, err := pgx.Connect(context.Background(), url)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err)
		os.Exit(1)
	}
	db = conn
	fmt.Println("db connected")
}
